package com.whcoding.druid.monitor.service.impl;

import com.whcoding.druid.monitor.dao.DeptDao;
import com.whcoding.druid.monitor.pojo.OrmDeptVO;
import com.whcoding.druid.monitor.service.DeptService;
import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Manager
 */
@Service
public class DeptServiceImpl implements DeptService {

	private static final Logger log = LoggerFactory.getLogger(DeptServiceImpl.class);

	@Autowired
	private DeptDao dao;

	/**
	 * 查询数据-ID
	 *
	 * @param id
	 * @return
	 */
	@Override
	public OrmDeptVO queryDeptById(Long id) {
		sleepTime(10);
		return dao.queryDeptById(id);
	}

	/**
	 * 查询全部数据
	 *
	 * @return
	 */
	@Override
	public List<OrmDeptVO> queryAllDept() {
		return dao.queryAllDept();
	}

	/**
	 * 程序休眠多少秒
	 *
	 * @param second
	 */
	private void sleepTime(Integer second) {
		try {
			Thread.sleep(1000 * second);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}
}
